#include <iostream>
using namespace std;
#define gua(i,a,b) for(int i=(a);i<=(b);++i)
char mp[10005][10005];
int sx[]={1,0,-1,0},sy[]={0,-1,0,1};
int m,n,x,y,ans;
void dg(int a,int b){
    ++ans;
    gua(i,0,3){
        int xx=a+sx[i],yy=b+sy[i];
        if(mp[xx][yy]=='.'){
            mp[xx][yy]='#';
            dg(xx,yy);
        }
    }
}
int main(){
    cin>>m>>n;
    gua(i,1,n)gua(j,1,m){
        cin>>mp[i][j];
        if(mp[i][j]=='@'){x=i;y=j;}
    }
    dg(x,y);
    cout<<ans<<endl;
    return 0;
}
